$(document).ready(function(){
    var date = new Date()
    var detailDate = date.getFullYear()+"-"+(date.getMonth()+1)+"-"+date.getDate()
    $(".theDate").html(detailDate)
    $.ajax({
        type:"post",
        url:"/getGlobalNum",
        dataType:"json",
        success: function(data){
            $("#globalConfirmedNum").html(data.globalConfirmedNum)
            $("#addConfirmedNum").html(data.addConfirmedNum)
            $("#NumList").empty()
            var th = '<tr> <th>省/州</th> <th>国家/地区</th> <th>目前确诊病例数</th> <th>较昨日新增确诊数</th> </tr>'
            $("#NumList").append(th)
            for(var i = 0;i<data.list.length;i++) {
                var tr;
                tr='<td>'+data.list[i].province+'</td>'+'<td>'+data.list[i].country+'</td>'+'<td>'+data.list[i].nowTotalNum+'</td>'+'<td>'+data.list[i].addNum+'</td>'
                $("#NumList").append('<tr>'+tr+'</tr>');
            }
            $(".countryName").html("全球")
        }
    });
});
function getDataByCountryName() {
    var countryName = $("#searchCountryName").val();
    if(countryName != "") {
        $.ajax({
            type: "post",
            url: "/getOneCountryNum",
            data: {searchCoutryName: countryName},
            dataType: "json",
            success: function (data) {
                $("#globalConfirmedNum").html(data.globalConfirmedNum)
                $("#addConfirmedNum").html(data.addConfirmedNum)
                $(".countryName").html(countryName)
                $("#NumList").empty()
                var th = '<tr> <th>省/州</th> <th>国家/地区</th> <th>目前确诊病例数</th> <th>较昨日新增确诊数</th> </tr>'
                $("#NumList").append(th)
                for (var i = 0; i < data.list.length; i++) {
                    var tr;
                    tr = '<td>' + data.list[i].province + '</td>' + '<td>' + data.list[i].country + '</td>' + '<td>' + data.list[i].nowTotalNum + '</td>' + '<td>' + data.list[i].addNum + '</td>'
                    $("#NumList").append('<tr>' + tr + '</tr>');
                }

            }
        });
    }
}